package Test;

import java.util.*;

/**
 * @author Kevin
 * @date 2020/4/5 10:57
 * 解题方法：dfs
 * 问题：每个城市i有个传送门，
 * 传送到a[i]，花费A
 * 传送到a[i]-1， 花费B
 * 传送到a[i]+1，花费C
 * 试问从城市1出发到城市N，最少的花费
 * 第一行  N，A，B，C
 * 第二行  a[1], a[2] ... a[N]
 * e.g.
 * 7  1  1  1
 * 3  6  4  3  4  5  6
 * 输出：4
 */
public class Main {
    static int maxCost = Integer.MAX_VALUE;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        //a[n]
        List<Integer> list = new ArrayList();
        for(int i = 0; i < num; i++) {
            int temp = sc.nextInt();
            list.add(temp);
        }
        boolean[] visited = new boolean[num+1];
        // 0 号城市作废，i取  1-N
        dfs(list, A, B, C, 1, num, 0, visited);

        System.out.println(maxCost);
    }

    static void dfs(List<Integer> list, int A, int B, int C, int i, int N, int cost, boolean[] visited) {
        // 判断当前城市值
        if (i == N) {
            if (cost < maxCost) {
                maxCost = cost;
                return;
            }
        }
        visited[i] = true;
        // 当前城市不是N，传送
        if (visited[list.get(i-1)] == false) {
            dfs(list, A, B, C, list.get(i-1), N, cost+A, visited);
        }
        if (list.get(i-1)-1 >= 1 && visited[list.get(i-1)-1] == false) {
            dfs(list, A, B, C, list.get(i-1)-1, N, cost+B, visited);
        }
        if (list.get(i-1)+1 <= N && visited[list.get(i-1)+1] == false) {
            dfs(list, A, B, C, list.get(i-1)+1, N, cost+C, visited);
        }
    }

}
